﻿Imports NHibernate
Imports NHibernate.Criterion
Imports TodoMicroSolutionPackV1.productos.dal.dto
Imports TodoMicroSolutionPackV1.dal.dao
Namespace productos.dal.dao
    Public Class productoDAO
        Inherits GenericNHibernateDAO(Of producto, Integer)
        Public Function buscarProductos(ByVal id As Integer, ByVal codigo As String, ByVal descripcion As String) As IList(Of producto)
            Dim criteria As ICriteria = session.CreateCriteria(Of producto)()

            If (id <> 0) Then criteria.Add(Expression.Eq("id", id))
            If (codigo <> "") Then criteria.Add(Expression.Like("codigo", codigo, MatchMode.Anywhere))
            If (descripcion <> "") Then criteria.Add(Expression.Like("descripcion", descripcion, MatchMode.Anywhere))
            Return criteria.List(Of producto)()

        End Function
        Public Sub New(ByRef session As ISession)
            MyBase.New(session)
        End Sub
    End Class
End Namespace

